<template>
  <header class="title-text" :style="style">
    <h3 class="title-text-label" :class="{ sub: subTitle }">{{ title }}</h3>
    <section class="title-text-action">
      <slot></slot>
    </section>
  </header>
</template>

<script setup>
import { computed } from 'vue'
const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  fontSize: {
    type: Number,
    default: 0
  },
  subTitle: {
    type: Boolean,
    default: false
  }
})
const style = computed(() => ({ fontSize: props.fontSize ? `${props.fontSize}px` : '' }))
</script>

<style lang="scss" scoped>
.title-text {
  // 
  display: flex;
  align-items: center;
  justify-content: space-between;

  &-label {
    position: relative;
    font-weight: bold;
    color: var(--el-color-black);
    font-size: var(--el-font-size-large);
    padding-left: var(--ycy-gap-base);
    line-height: 1;

    &::before {
      position: absolute;
      left: 0;
      content: '';
      width: 4px;
      height: 100%;
      border-radius: var(--el-border-radius-base);
      background-color: var(--el-color-primary);
      margin-right: var(--ycy-gap-base);
    }

    &.sub {
      &::before {
        top: 50%;
        transform: translateY(-50%);
        width: 6px;
        height: 6px;
      }
    }
  }

  &-action {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
}
</style>